package com.token.sysflow.core;
import com.token.sql.IntegrateSql;
import com.token.sysflow.impl.AbstractFlowHandlerImpl;
import com.token.sysflow.impl.SubmitFlowImpl;


/**
 * @author chenjianxiong 2020/4/13
 */
public class SysSetFlow extends SubmitFlow{
    public SysSetFlow(IntegrateSql f, String keyUnid) throws Exception{
        super(f,keyUnid);
    }


    @Override
    public void execute(AbstractFlowHandlerImpl flowHandler) throws Exception{
        submitFlow = (SubmitFlowImpl) flowHandler;

        //设置目标流程
        super.setToFlowById(submitFlow.getFlowId());

        //设置目标环节
        super.setToStepById(submitFlow.getStepId());

        //初始化起草人、申请人、当前人。
        initUserInfo(null,null,submitFlow.getActionUser());

        //删除当前的办理人
        approveProcess.delStepAllApproves(getFromStep());

        //更新审批数据
        super.updateApproveProcess(flowHandler);

        //写入办理人
        approveProcess.addToStepApprover(submitFlow.getSelectApprover());

        //根据环节类型来提交。
        super.submitByToStepType(submitFlow.getActionUser());


        //生成新的流转记录和办理意见
        super.createFlowApproveLog(flowHandler);

    }
}
